<?php


namespace App\HttpController\Test;

use EasySwoole\Http\AbstractInterface\Controller;
use Extend\Network\Curl;
use Extend\Sign\SortSign;
use EasySwoole\EasySwoole\Config;
use EasySwoole\Queue\Job;
use App\Utility\MyQueue;

class TestQueue extends Controller
{

    public function index()
    {

        $job = new Job();

        $num = 10;
        for ($i = 0; $i < $num; $i++) {
            //发送到队列
            $jobData = [
                // 'host' => $host,
                // 'protocol' => $protocol,
                // 'port' => $port,
                // 'ssl' => $ssl,
                // 'path' => $path,
                'url' => '',
                'method' => 'GET',
                'params' => '',
                'time' => time(),
            ];

            //投递任务
            $job->setJobData($jobData);
            MyQueue::getInstance()->producer()->push($job);
        }

        $this->response()->write("send {$num} task");

    }
}
